﻿using System;
using System.Collections.Generic;

namespace SRB.Tg.Model
{
    public class GeneralRebar : RebarBase
    {
        public List<double> LineSegmentList;
        public List<RebarBend> BendList;
        public RebarEnd StartHook;
        public RebarEnd EndHook;

        // 钢筋外径
        public static Dictionary<eRebarDia, double> outerDia = new Dictionary<eRebarDia, double>()
        {
            {  eRebarDia.D6 , 6},
            {  eRebarDia.D8 , 8},
            {  eRebarDia.D10 , 11.3},
            {  eRebarDia.D12 , 13},
            {  eRebarDia.D14 , 15.5},
            {  eRebarDia.D16 , 17.5},
            {  eRebarDia.D18 , 20},
            {  eRebarDia.D20 , 22},
            {  eRebarDia.D22 , 24},
            {  eRebarDia.D25 , 27},
            {  eRebarDia.D28 , 30},
            {  eRebarDia.D32 , 34.5},
            {  eRebarDia.D36 , 39.5},
            {  eRebarDia.D40 , 43.5},
        };
        public static Dictionary<eDB, double> outerDiaOld = new Dictionary<eDB, double>()
        {
            {  eDB.DB6 , 6},
            {  eDB.DB8 , 8},
            {  eDB.DB10 , 11.3},
            {  eDB.DB12 , 13},
            {  eDB.DB14 , 15.5},
            {  eDB.DB16 , 17.5},
            {  eDB.DB18 , 20},
            {  eDB.DB20 , 22},
            {  eDB.DB22 , 24},
            {  eDB.DB25 , 27},
            {  eDB.DB28 , 30},
            {  eDB.DB32 , 34.5},
            {  eDB.DB36 , 39.5},
            {  eDB.DB40 , 43.5},
        };
        public static Dictionary<eDB, double> outerDiaNew = new Dictionary<eDB, double>()
        {
            {  eDB.DB6 , 6},
            {  eDB.DB8 , 8},
            {  eDB.DB10 , 11.6},
            {  eDB.DB12 , 13.9},
            {  eDB.DB14 , 16.2},
            {  eDB.DB16 , 18.4},
              {  eDB.DB18 , 20.5},
            {  eDB.DB20 , 22.7},
            {  eDB.DB22 , 25.1},
            {  eDB.DB25 , 28.4},
            {  eDB.DB28 , 31.6},
            {  eDB.DB32 , 35.8},
            {  eDB.DB36 , 40.2},
            {  eDB.DB40 , 44.6},
        };
        /// <summary>
        /// 90度标准弯钩长度
        /// </summary>
        public static Dictionary<eDB, double> outerDiaHoke = new Dictionary<eDB, double>()
        {
            {  eDB.DB6 , 7},
            {  eDB.DB8 , 9.4},
            {  eDB.DB10 , 11.7},
            {  eDB.DB12 , 14.1},
            {  eDB.DB14 , 16.4},
            {  eDB.DB16 , 18.7},
            {  eDB.DB18 , 21.1},
            {  eDB.DB20 , 23.4},
            {  eDB.DB22 , 25.8},
            {  eDB.DB25 , 29.3},
            {  eDB.DB28 , 32.8},
            {  eDB.DB32 , 37.5},
            {  eDB.DB36 , 42.2},
            {  eDB.DB40 , 46.8},
        };
        /// <summary>
        /// 135度标准弯钩长度
        /// </summary>
        public static Dictionary<eDB, double> outerDia135Hoke = new Dictionary<eDB, double>()
        {
            {  eDB.DB6 , 7.2},
            {  eDB.DB8 , 9.7},
            {  eDB.DB10 , 12.1},
            {  eDB.DB12 , 14.5},
            {  eDB.DB14 , 16.9},
            {  eDB.DB16 , 19.3},
            {  eDB.DB18 , 21.7},
            {  eDB.DB20 , 24.1},
            {  eDB.DB22 , 26.6},
            {  eDB.DB25 , 30.2},
            {  eDB.DB28 , 33.9},
            {  eDB.DB32 , 38.6},
            {  eDB.DB36 , 43.4},
            {  eDB.DB40 , 48.3},
        };
        /// <summary>
        /// 180度标准弯钩长度
        /// </summary>
        public static Dictionary<eDB, double> outerDia180Hoke = new Dictionary<eDB, double>()
        {
            {  eDB.DB6 , 4.1},
            {  eDB.DB8 , 5.4},
            {  eDB.DB10 , 6.8},
            {  eDB.DB12 , 8.1},
            {  eDB.DB14 , 9.4},
            {  eDB.DB16 , 10.8},
            {  eDB.DB18 , 12.1},
            {  eDB.DB20 , 13.5},
            {  eDB.DB22 , 14.8},
            {  eDB.DB25 , 16.9},
            {  eDB.DB28 , 18.9},
            {  eDB.DB32 , 21.6},
            {  eDB.DB36 , 24.3},
            {  eDB.DB40 , 27},
        };

        public GeneralRebar(string typeName, eRebarClass clsName, eRebarDia diameter, RebarEnd startHook, RebarEnd endHook) :
            base(typeName, clsName, diameter)
        {
            Diameter = diameter;
            if (startHook == null)
            {
                throw new ArgumentNullException(nameof(startHook));
            }
            StartHook = startHook;
            if (endHook == null)
            {
                throw new ArgumentNullException(nameof(endHook));
            }
            EndHook = endHook;
            LineSegmentList = new List<double>();
            BendList = new List<RebarBend>();
        }

        public override double TotalLength
        {
            get
            {
                int d = Convert.ToInt32(Diameter);
                double res = 0;
                res += StartHook.AddLength(d);
                res += EndHook.AddLength(d);
                foreach (double dd in LineSegmentList)
                {
                    res += dd;
                }
                foreach (RebarBend rb in BendList)
                {
                    res -= rb.SubtractLength(d);
                }
                return res;
            }
        }


    }
}
